import request from '../utils/request.js'
export default {
	namespaced:true,
	actions:{
		async loginUp(context,userInfo){
			await request({
				url: "prod-api/login",
				method: "post",
				data:{
					username:userInfo.username,
					password:userInfo.password
				}
			}).then((res)=>{
				
				if(res.code<300){
					console.log(res)
					uni.setStorageSync("token",res.data.token);
					uni.setStorageSync("userInfo",userInfo)
					uni.switchTab({
						url: "/pages/home/index"
					});
				}else{
					uni.showToast({
					     title: '账号或密码输入错误',
					     icon: 'error',
					     duration: 2000//持续的时间
					   })
				}
				
			})		
		}
	},
	mutations:{
		
	},
	state:{
		userinfo:uni.getStorageSync("userInfo")
	},
}